<?php
/*
 * Created on Jan 19, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
?>
<?php
class Model_country extends Model {
	var $_tbl_name;

	function Model_country() {
		// Call the Model constructor
		parent :: Model();
		$this->_tbl_name = "tbl_country";
	}

	function fetch_all()
	{
		$query = $this->db->get($this->_tbl_name);
		if ($query->num_rows() > 0) {
			return $query->result_array();
		}
		return null;
	}

	function find($id){
		$this->db->where("country_id", $id);
		$query = $this->db->get($this->_tbl_name);
		if ($query->num_rows() > 0) {
			return $query->first_row("array");
		}
		return null;
	}

	/**
	 *
	 *
	 */
	function find_by_iso_2($iso_code_2){
		$this->db->where("iso_code_2", strtoupper($iso_code_2));
		$query = $this->db->get($this->_tbl_name);
		if ($query->num_rows() > 0) {
			return $query->first_row("array");
		}
		return null;
	}

	/**
	 *
	 *
	 */
	function find_by_ids($ids){
		$this->db->where_in("country_id", $ids);
		$query = $this->db->get($this->_tbl_name);
		if ($query->num_rows() > 0) {
			return $query->result_array();
		}
		return null;
	}
}
?>